<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<html:html locale="true">
<head>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
<title></title>
<link href="console.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
.even {
	background:	#eee;
}

.odd {

}
</style>
<link href="../console.css" rel="stylesheet" type="text/css">
</head>

<body>
<jsp:include page="/title.jsp" flush="true"/>
	<p class="lnkhead2"><bean:message key='menu.dataConnections'/>&gt;<bean:write name="domain"  filter="true"/></p>
	<form name="form" method="post" action="database.do">
	<table width="779" >
	  <!--DWLayoutTable-->
	  <tr class="txtnormal2">
	  <td   width="25%" align="right" ><bean:message key='menu.dataConnection'/>&nbsp;Id</td>
	  <td width="30%" align="left">
  	    <html:text name="config" property="id" maxlength="36"/>  	    <input type="hidden" name="domain" value='<bean:write name="config" property="id"/>'></td>
	  <td width="45%">&nbsp;</td>
	  </tr>
	
	<tr class="txtnormal2">
	  <td  align="right" ><bean:message key='dataconnection.type'/></td>
	  <td align="left">
        <html:select name="config" size="1" property="dialect" > 
        <option value=""></option> 
<html:options name="dialectlist"/> 

      </html:select></td>
	  <td>&nbsp;</td>
	</tr>
	<tr class="txtnormal2">
	  <td  align="right"><bean:message key='dataconnection.appServer'/></td>
	  <td  align="left">
        <html:select name="config" size="1" property="appserver" > 
        <option value=""><bean:message key='button.others'/></option>
       
<html:options name="appserverlist"/> 
              </html:select></td>
	  <td>&nbsp;</td>
	</tr>
	<tr class="txtnormal2">
	  <td  align="right"><bean:message key='dataconnection.transaction'/></td>
	  <td align="left">
        <html:select name="config" size="1" property="transaction_type" > 
        <html:options name="transactionlist"/> 
              </html:select></td>
	  <td>&nbsp;</td>
	</tr>
	<tr class="txtnormal2">
	  <td    align="right" >UserTransaction JNDI</td>
	  <td  align="left">
  	    <html:text name="config" property="jta_UserTransaction" maxlength="64"/>  	   </td>
	  <td ><bean:message key='dataconnection.note'/></td>
	  </tr>
	<tr class="txtnormal2">
	  <td align="right"><bean:message key='dataconnection.connectionType'/></td>
	  <td  align="left"><input name="type" type="radio" value="datasource"  onClick="javascript:typeChanged()">
	    <bean:message key='dataconnection.dataSource'/>
        <input type="radio" name="type" value="direct" onClick="javascript:typeChanged()">
        <bean:message key='dataconnection.direct'/></td>
	  <td>&nbsp;</td>
	</tr>
	</table> 
	   	<div id="form1"  style=" visibility:hidden; z-index:4" >
	<table width="779" >
	    <!--DWLayoutTable-->
	    <tr class="txtnormal2">
	        <td width="160" align="right"><bean:message key='dataconnection.dataSourceName'/></td>
          <td width="100"  align="left" > <html:text name="config" property="datasource" maxlength="36"/></td>
          <td width="80"  align="right" ></td>
          <td width="140"  align="left" ></td>
      <td >&nbsp;</td>
      </tr>
	  
      </table>
      </div>
      <div id="form2"  style=" visibility:hidden; z-index:4" >
	  	<table width="779" >
	    <!--DWLayoutTable-->
	    <tr class="txtnormal2">
	        <td width="25%" align="right" ><bean:message key='dataconnection.url'/></td>
          <td width="30%" align="left" > <html:text size="46" name="config" property="connection_url" maxlength="136"/></td>
          <td width="20%" align="right"><bean:message key='dataconnection.user'/></td>
          <td width="25%" align="left" > <html:text name="config" size="10" property="username" maxlength="36"/></td>
	    <td >&nbsp;</td>
	    </tr>
	  <tr class="txtnormal2">
	        <td  align="right"><bean:message key='dataconnection.class'/></td>
          <td align="left" > <html:text name="config"  size="46" property="driver_class" maxlength="136"/></td>
          <td align="right" ><bean:message key='dataconnection.password'/></td>
	      <td align="left" > <html:password name="config" size="10" property="password" maxlength="36"/></td>
	  <td>&nbsp;</td>
	  </tr>
      </table>
      </div>
	  <table width="779" >
	    <!--DWLayoutTable-->
	
		<tr class="txtnormal2">
	  <td width="97" height="43">&nbsp;</td>
	  <td width="54" valign="middle"><input  type="button" name="Submit" value="<bean:message key='button.update'/>" onclick="javascript:submit1('update')"></td>
	  <td width="12">&nbsp;</td>
	  <td width="72" valign="middle"><input type="reset" name="Submit2" value="<bean:message key='button.reset'/>"></td>
	  <td width="70" valign="middle"><input type="button" name="Submit3" value="<bean:message key='button.delete'/>" onclick="javascript:del()"></td>
	  <td width="89" valign="middle"><input type="button" name="Submit32" value="<bean:message key='dataconnection.test'/>" onclick="javascript:submit1('test')"></td>
		<td width="348">&nbsp;</td>
		</tr>
    </table>
    	<input type="hidden" name="act"/>

  
	</form>
	
	<logic:notEmpty name="returnMsg">
	<script>
	<logic:empty name="notRefrashTree">
	parent.frames[0].location.reload();
	</logic:empty>
	alert('<bean:write name="returnMsg"/>');
	</script>
	</logic:notEmpty>
	
	<script  language="JavaScript">
	var frm = document.forms["form"];
	<logic:equal name="config" property="type" value="datasource">
	frm.elements["type"][0].checked=true;</logic:equal>
	<logic:equal name="config" property="type" value="direct">
	frm.elements["type"][1].checked=true;</logic:equal>
	typeChanged();
	 function typeChanged(){
	var frm = document.forms["form"];

	if(frm.elements["type"][1].checked){
		form2.style.visibility = "visible";
		form1.style.visibility = "hidden";
	}else{
		form2.style.visibility = "hidden";
		form1.style.visibility = "visible";
		
	}
	 }
	 
	 function submit1(action){
	var frm = document.forms["form"];
		frm.elements["act"].value=action;
		if(frm.elements["transaction_type"].value=="JTA"){
		if(frm.elements["jta_UserTransaction"].value==""){
		alert("<bean:message key='dataconnection.needUserTransaction'/>");return;
		}
		}
		if(frm.elements["id"].value==""){
		 alert("<bean:message key='dataconnection.needDataConnectionId'/>");return;
		}
		if(frm.elements["dialect"].value==""){
		 alert("<bean:message key='dataconnection.needDatabaseType'/>");return;
		}
		//if(frm.elements["appserver"].value==""){
		// alert("±ØÐëÑ¡ÔñÓ¦ÓÃ·þÎñÆ÷£¡");return;
		//}
		if(frm.elements["type"][0].checked){
		frm.elements["type"].value="datasource";
		if(frm.elements["datasource"].value==""){
		 alert("<bean:message key='dataconnection.needDataSourceName'/>");return;
		}
		
		
		}else{
		frm.elements["type"].value="direct";
		if(frm.elements["connection_url"].value==""){
		 alert("<bean:message key='dataconnection.needUrl'/>");return;
		}
		if(frm.elements["driver_class"].value==""){
		 alert("<bean:message key='dataconnection.needClass'/>");return;
		 }
		if(frm.elements["username"].value==""){
		 alert("<bean:message key='dataconnection.needUser'/>");return;
		}
		
		}
	frm.submit();
	 }
	 
	 function del(){
	 if( !confirm("<bean:message key='button.confirmDelete'/>")) return;
	var frm = document.forms["form"];
	frm.elements["act"].value="delete";
	frm.submit();
	 }

	</script>
	
<%@ include file="/bottom.jsp" %>
</body>
</html:html>



